from PyQt5.QtCore import QThread, pyqtSignal

class WorkerThread(QThread):
    """
    自定义工作线程类，继承自QThread
    """
    # 定义信号：用于更新进度
    progress_updated = pyqtSignal(int)
    # 定义信号：任务完成时触发
    task_finished = pyqtSignal()

    def __init__(self, device_id, app, progressBar, statusBar):
        super().__init__()
        self.device = app  # 设备实例
        self.progressBar = progressBar  # 进度条实例
        self.device_id = device_id  # 设备id
        self.statusBar = statusBar  # 状态栏实例

    def run(self):
        """线程的核心执行逻辑"""
        self.device.run(self.device_id, self.progressBar, self.statusBar)
        self.task_finished.emit()  # 任务完成信号发射

